import 'package:flutter/material.dart';
import 'package:fzcgx_app/common/adapter_utils.dart';
import 'package:fzcgx_app/provider/provider_widget.dart';
import 'package:fzcgx_app/ui/base/base_view_model.dart';
import 'package:fzcgx_app/ui/my/factory/view_model/factory_production_capacity_view_model.dart';
import 'package:fzcgx_app/ui/widget/custom_appbar_widget.dart';

class FactoryProductionCapacityPage extends StatefulWidget {
  FactoryProductionCapacityPage({Key key, this.callback}) : super(key: key);
  final Function callback;
  @override
  _FactoryProductionCapacityPageState createState() =>
      _FactoryProductionCapacityPageState();
}

class _FactoryProductionCapacityPageState
    extends State<FactoryProductionCapacityPage> {
     
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      
      backgroundColor: Colors.white,
      appBar: CustomAppbar(
        title: '产量 产能',
      ),
      body: SafeArea(
          child: ProviderWidget<FactoryProductionCapacityViewModel>(
        model: FactoryProductionCapacityViewModel(),
        onReady: (viewModel) {
          viewModel.requestApi();
        },
        builder: (context, viewModel, child) {
          return viewModel.state==ViewState.Success? _buildSuccessWidget(viewModel):Container();
        },
      )),
    );
  }

  Widget _buildSuccessWidget(FactoryProductionCapacityViewModel viewModel) {
    return SingleChildScrollView(
      child: Column(
        children: <Widget>[
          SizedBox(
            height: AdapterUtils.getHeight(4),
          ),
          Container(
            height: AdapterUtils.getHeight(38),
            color: Color(0xffEAF7FE),
            child: Center(
              child: Text(
                '注册填写/上传的信息越全面，客户信任度越高',
                style: TextStyle(
                  fontSize: AdapterUtils.getSp(13),
                  color: Color(0xff15A1FF),
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(30),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            child: Column(
              children: <Widget>[
                Container(
                  decoration: BoxDecoration(
                      border: Border(
                          bottom:
                              BorderSide(color: Color(0xffE8E9ED), width: 1))),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      RichText(
                        text: TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '裁剪',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(14),
                                color: Color(0xff606B79),
                                fontWeight: FontWeight.w500,
                              )),
                          TextSpan(
                              text: '',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(14),
                                color: Color(0xffFF1515),
                                fontWeight: FontWeight.w500,
                              )),
                        ]),
                      ),
                      TextField(
                         controller: viewModel.caijianController,
                        keyboardType: TextInputType.numberWithOptions(),
                        style: TextStyle(
                          fontSize: AdapterUtils.getSp(18),
                          color: Color(0xff3B4859),
                          fontWeight: FontWeight.w500,
                        ),
                        decoration: InputDecoration(
                            contentPadding: EdgeInsets.only(
                                top: AdapterUtils.getHeight(10),
                                bottom: AdapterUtils.getHeight(20)),
                            hintText: '请输入（人）',
                            border: InputBorder.none,
                            hintStyle: TextStyle(
                              fontSize: AdapterUtils.getSp(18),
                              color: Color(0xffD7D8DB),
                              fontWeight: FontWeight.w500,
                            )),
                      )
                    ],
                  ),
                ),
                SizedBox(
                  height: AdapterUtils.getHeight(24),
                ),
                Container(
                  decoration: BoxDecoration(
                      border: Border(
                          bottom:
                              BorderSide(color: Color(0xffE8E9ED), width: 1))),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      RichText(
                        text: TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '整件',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(14),
                                color: Color(0xff606B79),
                                fontWeight: FontWeight.w500,
                              )),
                          TextSpan(
                              text: '',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(14),
                                color: Color(0xffFF1515),
                                fontWeight: FontWeight.w500,
                              )),
                        ]),
                      ),
                      TextField(
                         controller: viewModel.zhengjianController,
                        keyboardType: TextInputType.numberWithOptions(),
                        style: TextStyle(
                          fontSize: AdapterUtils.getSp(18),
                          color: Color(0xff3B4859),
                          fontWeight: FontWeight.w500,
                        ),
                        decoration: InputDecoration(
                            contentPadding: EdgeInsets.only(
                                top: AdapterUtils.getHeight(10),
                                bottom: AdapterUtils.getHeight(20)),
                            hintText: '请输入（人）',
                            border: InputBorder.none,
                            hintStyle: TextStyle(
                              fontSize: AdapterUtils.getSp(18),
                              color: Color(0xffD7D8DB),
                              fontWeight: FontWeight.w500,
                            )),
                      )
                    ],
                  ),
                ),
                SizedBox(
                  height: AdapterUtils.getHeight(24),
                ),
                Container(
                  decoration: BoxDecoration(
                      border: Border(
                          bottom:
                              BorderSide(color: Color(0xffE8E9ED), width: 1))),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      RichText(
                        text: TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '捆包流',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(14),
                                color: Color(0xff606B79),
                                fontWeight: FontWeight.w500,
                              )),
                          TextSpan(
                              text: '',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(14),
                                color: Color(0xffFF1515),
                                fontWeight: FontWeight.w500,
                              )),
                        ]),
                      ),
                      TextField(
                         controller: viewModel.kunbaoliuController,
                        keyboardType: TextInputType.numberWithOptions(),
                        style: TextStyle(
                          fontSize: AdapterUtils.getSp(18),
                          color: Color(0xff3B4859),
                          fontWeight: FontWeight.w500,
                        ),
                        decoration: InputDecoration(
                            contentPadding: EdgeInsets.only(
                                top: AdapterUtils.getHeight(10),
                                bottom: AdapterUtils.getHeight(20)),
                            hintText: '请输入（人）',
                            border: InputBorder.none,
                            hintStyle: TextStyle(
                              fontSize: AdapterUtils.getSp(18),
                              color: Color(0xffD7D8DB),
                              fontWeight: FontWeight.w500,
                            )),
                      )
                    ],
                  ),
                ),
                SizedBox(
                  height: AdapterUtils.getHeight(24),
                ),
                Container(
                  decoration: BoxDecoration(
                      border: Border(
                          bottom:
                              BorderSide(color: Color(0xffE8E9ED), width: 1))),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      RichText(
                        text: TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '单件流',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(14),
                                color: Color(0xff606B79),
                                fontWeight: FontWeight.w500,
                              )),
                          TextSpan(
                              text: '',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(14),
                                color: Color(0xffFF1515),
                                fontWeight: FontWeight.w500,
                              )),
                        ]),
                      ),
                      TextField(
                         controller: viewModel.danjianliunController,
                        keyboardType: TextInputType.numberWithOptions(),
                        style: TextStyle(
                          fontSize: AdapterUtils.getSp(18),
                          color: Color(0xff3B4859),
                          fontWeight: FontWeight.w500,
                        ),
                        decoration: InputDecoration(
                            contentPadding: EdgeInsets.only(
                                top: AdapterUtils.getHeight(10),
                                bottom: AdapterUtils.getHeight(20)),
                            hintText: '请输入（人）',
                            border: InputBorder.none,
                            hintStyle: TextStyle(
                              fontSize: AdapterUtils.getSp(18),
                              color: Color(0xffD7D8DB),
                              fontWeight: FontWeight.w500,
                            )),
                      )
                    ],
                  ),
                ),
                SizedBox(
                  height: AdapterUtils.getHeight(24),
                ),
                Container(
                  decoration: BoxDecoration(
                      border: Border(
                          bottom:
                              BorderSide(color: Color(0xffE8E9ED), width: 1))),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      RichText(
                        text: TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '全厂总人数',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(14),
                                color: Color(0xff606B79),
                                fontWeight: FontWeight.w500,
                              )),
                          TextSpan(
                              text: '',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(14),
                                color: Color(0xffFF1515),
                                fontWeight: FontWeight.w500,
                              )),
                        ]),
                      ),
                      TextField(
                         controller: viewModel.zongrenshuController,
                        keyboardType: TextInputType.numberWithOptions(),
                        style: TextStyle(
                          fontSize: AdapterUtils.getSp(18),
                          color: Color(0xff3B4859),
                          fontWeight: FontWeight.w500,
                        ),
                        decoration: InputDecoration(
                            contentPadding: EdgeInsets.only(
                                top: AdapterUtils.getHeight(10),
                                bottom: AdapterUtils.getHeight(20)),
                            hintText: '请输入（人）',
                            border: InputBorder.none,
                            hintStyle: TextStyle(
                              fontSize: AdapterUtils.getSp(18),
                              color: Color(0xffD7D8DB),
                              fontWeight: FontWeight.w500,
                            )),
                      )
                    ],
                  ),
                ),
                SizedBox(
                  height: AdapterUtils.getHeight(24),
                ),
                GestureDetector(
                  onTap: (){
                    viewModel.showPicker(context);
                  },
                  child: Container(
                    decoration: BoxDecoration(
                        border: Border(
                            bottom: BorderSide(
                                color: Color(0xffE8E9ED), width: 1))),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        RichText(
                          text: TextSpan(children: <InlineSpan>[
                            TextSpan(
                                text: '日产量',
                                style: TextStyle(
                                  fontSize: AdapterUtils.getSp(14),
                                  color: Color(0xff606B79),
                                  fontWeight: FontWeight.w500,
                                )),
                            TextSpan(
                                text: '',
                                style: TextStyle(
                                  fontSize: AdapterUtils.getSp(14),
                                  color: Color(0xffFF1515),
                                  fontWeight: FontWeight.w500,
                                )),
                          ]),
                        ),
                        TextField(
                          controller: viewModel.richanliangController,
                          enabled: false,
                          keyboardType: TextInputType.numberWithOptions(),
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          ),
                          decoration: InputDecoration(
                              contentPadding: EdgeInsets.only(
                                  top: AdapterUtils.getHeight(10),
                                  bottom: AdapterUtils.getHeight(20)),
                              hintText: '请选择',
                              border: InputBorder.none,
                              hintStyle: TextStyle(
                                fontSize: AdapterUtils.getSp(18),
                                color: Color(0xffD7D8DB),
                                fontWeight: FontWeight.w500,
                              )),
                        )
                      ],
                    ),
                  ),
                ),
                SizedBox(
                  height: AdapterUtils.getHeight(20),
                ),
                Container(
                    width: AdapterUtils.screenWidth(),
                    height: AdapterUtils.getHeight(50),
                    margin: EdgeInsets.all(15),
                    child: FlatButton(
                        onPressed: () {
                          viewModel.postApi(context,widget.callback);
                        },
                        disabledColor: Color(0xff15A1FF).withAlpha(80),
                        color: Color(0xff15A1FF),
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.all(Radius.circular(4)),
                        ),
                        child: Text(
                          '保存',
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(16),
                            color: Colors.white,
                            fontWeight: FontWeight.w500,
                          ),
                        ))),
              ],
            ),
          )
        ],
      ),
    );
  }
}
